﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

class Program
{
    static void Main(string[] args)
    {
        //string text = "Testing is important. We need to test everything.";

        //Regex r = new Regex(@"\w*test\w*", RegexOptions.IgnoreCase);
        //Match m = r.Match(text);
        //while (m.Success)
        //{
        //    Console.WriteLine(m.Value);
        //    m = m.NextMatch();
        //}

        string number = "1";
        string inputString = "0 0.0 0.5 -0.5 1.55 1 150 -30 -1.55 -0 -0.0 +5 5. 2-3 ..25 5..5 5.5.5 1.5e7 .0 -.5 .5 -00.5 00.25";
        string[] numbers = inputString.Split(' ');

        string pattern = @"\A0\Z|                                   #
                           \A0\.[0-9]+\Z|                           #
                           \A-0\.0*[1-9]+[0-9]*\Z|                  #
                           \A-?[1-9]{1}[0-9]*\.?[0-9]+\Z|           #
                           \A-?[1-9]{1}[0-9]*\Z                     #";
        Regex r = new Regex(pattern, RegexOptions.IgnorePatternWhitespace);
        Console.WriteLine(r.IsMatch(number));

        foreach (var item in numbers)
        {
            if (r.IsMatch(item))
            {
                Console.WriteLine(item);
            }
        }

        pattern = @"\A[a-zA-Z0-9]+[a-zA-Z0-9\._]*@[a-zA-Z0-9]+.([a-zA-Z0-9]+\.)*[a-zA-Z]{2,4}\Z";
        string email = "123.dsfgdf__3.23@gma23il.sasddsf.asd.com";
        Regex r2 = new Regex(pattern);
        Console.WriteLine(r2.IsMatch(email));

        pattern = @"\A(?<protocol>[a-zA-Z]+)://(?<host>[a-zA-Z0-9]+\.([a-zA-Z0-9]+\.)*[a-zA-Z]{2,4})(?<resource>/[a-zA-Z0-9]+(/[a-zA-Z0-9]+)*.[a-zA-Z0-9]+)\Z";
        string url = "http://www.devbg.org/forum/index.php";
        Regex r3 = new Regex(pattern);
        Match m2 = r3.Match(url);

        if(m2.Success)
        {
            Group g1 = m2.Groups["protocol"];
            Group g2 = m2.Groups["host"];
            Group g3 = m2.Groups["resource"];
            Console.WriteLine("[protocol] = {0}, [host] = {1}, [resource] = {2}", g1, g2, g3);
        }

        inputString = "asd#$asd123ds 123s2 jhfdhg 1";
        pattern = @"\D+";
        numbers = Regex.Split(inputString, pattern);
        foreach (var item in numbers)
        {
            Console.WriteLine(item);
        }
    }
}

